package com.banshuibao.bsb_android.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.widget.ImageView;
import android.widget.TextView;

import com.banshuibao.bsb_android.R;
import com.banshuibao.bsb_android.model.ConsutationModel;
import com.banshuibao.bsb_android.util.ImageUtil;
import com.banshuibao.bsb_android.util.PriceUtil;
import com.banshuibao.bsb_android.util.TimeUtil;

import java.util.List;

/**
 * Created by Administrator on 2017/12/22.
 */

public class ConsultationTwoAdapter extends MineBaseAdapter<ConsutationModel.DataBean> {

    private Context context;

    public ConsultationTwoAdapter(Context context, List<ConsutationModel.DataBean> data, int layoutResId) {
        super(context, data, layoutResId);
        this.context = context;
    }

    @Override
    protected void bindData(ViewHolder holder, ConsutationModel.DataBean item) {

        TextView content = (TextView) holder.getView(R.id.item_tab_two_content);
        TextView date = (TextView) holder.getView(R.id.item_tab_two_date);
        TextView status = (TextView) holder.getView(R.id.item_tab_two_status);
        TextView money = (TextView) holder.getView(R.id.item_tab_two_money);
        TextView name = (TextView) holder.getView(R.id.item_tab_two_name);
        ImageView img = (ImageView) holder.getView(R.id.item_tab_two_img);

        name.setText(item.getName());
        ImageUtil.loadImageHead(context, item.getHeadImg(), img);
        content.setText(item.getContent());
        String time = null;
        if (item.getCreateDate() != 0) {
            time = TimeUtil.format(item.getCreateDate());
        } else {
            time = "";
        }
        date.setText(time);
        money.setText("¥" + PriceUtil.FormatDecimal(item.getPrice()));
        //我答得状态
        String ansStatus = item.getAnsStatus();
        if (!TextUtils.isEmpty(ansStatus)) {
            if (ansStatus.equals("0")) {
                status.setText("未被采纳");
            } else if (ansStatus.equals("1")) {
                status.setText("已被采纳");
            }
        }
    }
}
